2.Basketball machine Slider <<
Previous 3.Basketball machine by (MTB_Robot)
使用老師的ik程式,使Mtb_robot放球到最終的位置(x=1.002,y=0)
但是把MTB_robot放到籃球機的場景裡,不能直接在程式裡打ik(1.002,0),因為MTB_robot沒有在座標原點上,所以要減掉MTB_robot的座標(0.7496,-2.3502),得出(0.2506,2.3502),才會移動到正確的座標。
操作說明
鍵盤操作

conveyorBelt 程式:
function sysCall_init()
pathHandle=sim.getObjectHandle("Path")
forwarder=sim.getObjectHandle('conveyorForwarder')
sim.setPathTargetNominalVelocity(pathHandle,0) -- for backward compatibility
end
function sysCall_cleanup()
end
function sysCall_actuation()
beltVelocity=sim.getScriptSimulationParameter(sim.handle_self,"conveyorBeltVelocity")
local dt=sim.getSimulationTimeStep()
local pos=sim.getPathPosition(pathHandle)
pos=pos+beltVelocity*dt*10
sim.setPathPosition(pathHandle,pos) -- update the path's intrinsic position
-- Here we "fake" the transportation pads with a single static rectangle that we dynamically reset
-- at each simulation pass (while not forgetting to set its initial velocity vector) :
local relativeLinearVelocity={-beltVelocity,0,0}
-- Reset the dynamic rectangle from the simulation (it will be removed and added again)
sim.resetDynamicObject(forwarder)
-- Compute the absolute velocity vector:
local m=sim.getObjectMatrix(forwarder,-1)
m[4]=0 -- Make sure the translation component is discarded
m[8]=0 -- Make sure the translation component is discarded
m[12]=0 -- Make sure the translation component is discarded
local absoluteLinearVelocity=sim.multiplyVector(m,relativeLinearVelocity)
-- Now set the initial velocity of the dynamic rectangle:
sim.setObjectFloatParameter(forwarder,sim.shapefloatparam_init_velocity_x,absoluteLinearVelocity[1])
sim.setObjectFloatParameter(forwarder,sim.shapefloatparam_init_velocity_y,absoluteLinearVelocity[2])
sim.setObjectFloatParameter(forwarder,sim.shapefloatparam_init_velocity_z,absoluteLinearVelocity[3])
end
2.Basketball machine Slider <<
Previous